# -*- encoding=utf8 -*-
"""
RedFlag-TC000096   （拍摄进入装饰页）剪辑铺满功能
使用铺满功能场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()

log("--------------------------------使用铺满功能场景--------------------------------------")
"""
点击进入拍照
调整摄像头
点击拍照按钮
等待
点击剪辑
点击旋转
点击保存
进行截图
点击剪辑
点击铺满
点击保存
断言
"""

shooter.enter_photo()
shooter.ensure_back_camera()
shooter.click_element(take_pictures_button)
shooter.wait_for_text_not_equal(background_music_name_text, "配乐中",interval=1)
shooter.click_element(edit_button)
sleep(1.0)
shooter.click_element(edit_rotate)
shooter.click_element(edit_save)
photo1 = shooter.capture_screenshot(file_name = "TC000093A.png")
shooter.click_element(edit_button)
shooter.click_element(edit_cover)
shooter.click_element(edit_save)
photo2= shooter.capture_screenshot(file_name = "TC000093B.png")
shooter.assert_images_not_equal(photo1, photo2, "断言失败，图片比对高度一致，说明铺满未成功", threshold=0.98)

# 关闭应用
stop_app(UGC_package_name)